class TimerUtils {
  ///@param int 秒
  ///@return  X天X时X分钟X秒

  ///余数
  static var remainder = 0;

  static getTimer(num second,
      {String end = "", day = "天", hour = "小时", min = "分钟", seconds = "秒"}) {
    remainder = second;
    String timer =
        "${toDays(remainder)}$day${toHours(remainder)}$hour${toMinutes(remainder)}$min${toSeconds(remainder)}$seconds$end";

    return timer;
  }

  static String toSeconds(num date) {

    if (0 <= date && date < 10) {
      return "0${date}";
    }

    return "${date}";

  }

  static String toMinutes(num date) {
    remainder = date % 60;

    var num = date ~/ 60;
    if (0 <= num && num < 10) {
      return "0${num}";
    }

    return "${num}";
  }

  static String toHours(num date) {
    remainder = date % (60 * 60);
    var num = date ~/ (60 * 60);

    if (0 <= num && num < 10) {
      return "0${num}";
    }

    return "${num}";
  }

  static String toDays(num date) {
    remainder = date % (24 * 60 * 60);
    var num = date ~/ (24 * 60 * 60);
    if (0 <= num && num < 10) {
      return "${num}";
    }

    return "${num}";
  }
}
